import React, {useEffect, useState} from 'react';
import {Button, Descriptions} from "antd";

function PreviousTyreSelect(props, state) {
    const [W, setW] = useState(null);
    const [F_2, setF_2] = useState(null);
    const [F_3, setF_3] = useState(null);
    const [V, setV] = useState(null);
    const [preMaxLoad, setpreMaxLoad] = useState(null);
    const [preBrakeLoad, setpreMaxBrakeLoad] = useState(null);
    const [preTotal, setPreTotal] = useState(null);
    const calculate = () => {
        const preMaxLoad = F_2*1.25/props.previousTyreNum;
        const preBrakeLoad = F_3*1.25/props.previousTyreNum;
        setpreMaxLoad(preMaxLoad);
        setpreMaxBrakeLoad(preBrakeLoad);
        setPreTotal(preMaxLoad+preBrakeLoad)
    };
    useEffect(() => {
        setW(props.W)
        setF_2(props.F_2)
        setF_3(props.F_3)
        setV(props.V)
    }, []);
    return (
        <div>
            <div style={{width: "100%"}}>
                <div>
                    <h3 style={{
                        fontWeight: "bold",
                        fontSize: "18px",
                        display: "inline-block",
                        width: "80px"
                    }}>输入参数</h3>
                    <Button onClick={calculate} type={"primary"} style={{paddingLeft:"10px"}}>计算</Button>
                </div>
                <Descriptions bordered column={4}>
                    <Descriptions.Item label="飞机的最大总重(kg)" span={2}>{W}</Descriptions.Item>
                    <Descriptions.Item label="前起落架最大停机载荷(kN)" span={2}>{F_2}</Descriptions.Item>
                    <Descriptions.Item label="前起落架最大刹车的前轮载荷(kN)" span={2}>{F_3}</Descriptions.Item>
                    <Descriptions.Item label="飞机地面最大速度(km/h)" span={2}>{V}</Descriptions.Item>
                </Descriptions>
                <h3 style={{
                    fontWeight: "bold",
                    fontSize: "18px",
                    display: "inline-block",
                    width: "80px"
                }}>计算结果</h3>
                <Descriptions  bordered column={2}>
                    <Descriptions.Item label="前起落架轮胎停机载荷(kN)" span={2}>{preMaxLoad}</Descriptions.Item>
                    <Descriptions.Item label="前起落架刹车载荷(kN)" span={2}>{preBrakeLoad}</Descriptions.Item>
                    <Descriptions.Item label="停机与刹车载荷叠加值(kN)"
                                       span={2}>{preTotal}</Descriptions.Item>
                </Descriptions>
            </div>
        </div>
    );
}

export default PreviousTyreSelect;